<?php

/**
 * This is the model class for table "GiaoVien".
 *
 * The followings are the available columns in table 'GiaoVien':
 * @property integer $MaGV
 * @property string $Ho
 * @property string $Ten
 * @property integer $GioiTinh
 * @property string $NgaySinh
 * @property string $NoiSinh
 * @property string $DanToc
 * @property string $TrinhDo
 * @property string $ChuyenMon
 * @property string $DiaChi
 * @property integer $DiDong
 * @property string $ChucVu
 * @property string $Username
 * @property integer $TrangThai
 *
 * The followings are the available model relations:
 * @property Lop[] $lops
 * @property PhanCong[] $phanCongs
 */
class GiaoVien extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return GiaoVien the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'GiaoVien';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('Ho, Ten, GioiTinh, NgaySinh, NoiSinh, DanToc, TrinhDo, DiaChi', 'required'),
			array('GioiTinh, DiDong, TrangThai', 'numerical', 'integerOnly'=>true),
			array('Ho, Ten, NoiSinh, DanToc, TrinhDo, ChuyenMon, DiaChi, ChucVu, Username', 'length', 'max'=>20),
			array('NgaySinh', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('MaGV, Ho, Ten, GioiTinh, NgaySinh, NoiSinh, DanToc, TrinhDo, ChuyenMon, DiaChi, DiDong, ChucVu, Username, TrangThai', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'lops' => array(self::HAS_MANY, 'Lop', 'MaGVCN'),
			'phanCongs' => array(self::HAS_MANY, 'PhanCong', 'MaGV'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'MaGV' => 'Ma Gv',
			'Ho' => 'Ho',
			'Ten' => 'Ten',
			'GioiTinh' => 'Gioi Tinh',
			'NgaySinh' => 'Ngay Sinh',
			'NoiSinh' => 'Noi Sinh',
			'DanToc' => 'Dan Toc',
			'TrinhDo' => 'Trinh Do',
			'ChuyenMon' => 'Chuyen Mon',
			'DiaChi' => 'Dia Chi',
			'DiDong' => 'Di Dong',
			'ChucVu' => 'Chuc Vu',
			'Username' => 'Username',
			'TrangThai' => 'Trang Thai',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('MaGV',$this->MaGV);
		$criteria->compare('Ho',$this->Ho,true);
		$criteria->compare('Ten',$this->Ten,true);
		$criteria->compare('GioiTinh',$this->GioiTinh);
		$criteria->compare('NgaySinh',$this->NgaySinh,true);
		$criteria->compare('NoiSinh',$this->NoiSinh,true);
		$criteria->compare('DanToc',$this->DanToc,true);
		$criteria->compare('TrinhDo',$this->TrinhDo,true);
		$criteria->compare('ChuyenMon',$this->ChuyenMon,true);
		$criteria->compare('DiaChi',$this->DiaChi,true);
		$criteria->compare('DiDong',$this->DiDong);
		$criteria->compare('ChucVu',$this->ChucVu,true);
		$criteria->compare('Username',$this->Username,true);
		$criteria->compare('TrangThai',$this->TrangThai);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}